

# https://github.com/arvidn/libtorrent/pull/4123
# using submodule b/c it has to be the master branch
CFLAGS=-I"./include/" -I"./deps/libtorrent/include/" -I"./deps/"
# -I"./deps/libtorrent/include/libtorrent/" 
LDFLAGS=  -Dwebtorrent=ON -DTORRENT_USE_OPENSSL -lpthread -lcurl -lcurlpp -lcurses
# -lcurses -lboost_system -ltorrent-rasterbar 

# building libtorrent with webtorrent support
# git submodule init --recursive
# cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -Dwebtorrent=ON -G Ninja ..
LIBTORRENT= ./deps/libtorrent/build/libtorrent-rasterbar.so.2.0.5
#  -Wl,-soname 

LD_LIBRARY_PATH=./deps/libtorrent/build/

all: | main
	# something to avoid prepending LD_LIBRARY_PATH=./deps/... every time.
	# better if compilted to just search in relative path to begin with
	patchelf  --remove-needed libtorrent-rasterbar.so.2.0 cppia
	patchelf  --add-needed ./deps/libtorrent/build/libtorrent-rasterbar.so.2.0 cppia
main: 
	g++ ./src/main.cpp $(CFLAGS) $(LDFLAGS) $(LIBTORRENT) -std=c++17 -o cppia -g

ncurses:
	g++ demo_window.cpp -lcurses -o window 

# OPENAPI_GENERATOR=/home/user/Programs/openapi-generator-cli.jar
# PEERTUBE_API=./deps/peertube/
# openapi:
# 	java -jar $(OPENAPI_GENERATOR) generate -i peertube.yaml -g c -o $(PEERTUBE_API)

# video:
# 	g++ ./deps/peertube/model/video.c -std=c++17

.PHONY: clean
clean: 
	rm cppia
